package de.jmda.home.bl.usermgmt;

import java.util.List;

import javax.ejb.Local;
import javax.mail.MessagingException;
import javax.mail.internet.AddressException;

import de.jmda.cbo.user.RegistrationRequest;
import de.jmda.cbo.user.User;

@Local
public interface UserManagementLocal
{
	/**
	 * @return all users in db
	 */
	List<User> allUsers();

	/**
	 * @param prefix
	 * @return string representation of all users in db
	 */
	String allUsersAsString(String prefix);

	/**
	 * @param username
	 * @return user matching the unique username
	 */
	User findUserByUsername(String username);

	/**
	 * adds user 
	 * @param user
	 */
	void createUser(User user);

	/**
	 * adds registration request for user admin
	 *
	 * @throws AddressException
	 * @throws MessagingException
	 */
	void createAdminRegistrationRequest()
			throws AddressException, MessagingException;

	/**
	 * @param username
	 * @return registration request matching username
	 */
	RegistrationRequest findRegistrationRequestByUserName(String username);

	/**
	 * Tries to find a registration request for parameter input. If successful an
	 * attempt to create a user for the parameter input will be made.
	 * 
	 * @param username
	 * @param password
	 * @return name of newly created user if creation was successful
	 */
	String findRegistrationRequestUsernameByUsernameRegistrationCode(
			String username, String password);

	void changePassword(
			String username,
			String passwordOld,
			String passwordNew,
			String passwordNewConfirm);

	void createRegistrationRequest(String username, String email);
}